import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ItemData } from "../../../resource/info/ItemData";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { BaseItem } from "../../common/BaseItem";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { EColor } from "../../../../../Message/Public/EColor";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { MountUtil } from "../../../scene/mount/MountUtil";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { StringHelper } from "../../../../../com/gengine/utils/StringHelper";
import { MsgManager } from "../../../manager/MsgManager";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTextInput } from "../../../../../com/mui/controls/GTextInput";
import { _mainInfo } from "../../../../../this/_mainInfo";
import { _deputyInfo } from "../../../../../this/_deputyInfo";
import { _growthSelect } from "../../../../../this/_growthSelect";
type int = number;
//class MountExtendAlertWindow
    
    export  class MountExtendAlertWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this._keyTxArr = [];
            this._bmArr = [];
            if (MountExtendAlertWindow._instance) 
            {
                throw new Error("PetExtendAlertWindow单例");
            }
            this.init();
            return;
        }

        public set mainInfo(arg1: ItemData)
        {
            this._mainInfo = arg1;
            this._baseItem.itemData = this._mainInfo;
            return;
        }

        public set growthSelect(arg1: int)
        {
            this._growthSelect = arg1;
            return;
        }

        public static get instance(): MountExtendAlertWindow
        {
            if (MountExtendAlertWindow._instance == null) 
            {
                MountExtendAlertWindow._instance = new MountExtendAlertWindow();
            }
            return MountExtendAlertWindow._instance;
        }

        
        {
            MountExtendAlertWindow.NormalMode = 0;
            MountExtendAlertWindow.ValidateMode = 1;
        }

        public set huanLv(arg1: int)
        {
            this._huanLv = arg1;
            if (this._huanLv > 0) 
            {
                (this._keyTxArr[1] as Object /* flash.text.TextField */).htmlText = "<font color=\'#00ff00\'>" + "+" + this._huanLv + "</font>";
                (this._bmArr[1] as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeRaise);
                (this._bmArr[2] as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeRaise);
            }
            else 
            {
                (this._keyTxArr[1] as Object /* flash.text.TextField */).htmlText = "<font color=\'#00ff00\'>" + Language.getString(70206) + "</font>";
                (this._bmArr[1] as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeSame);
                (this._bmArr[2] as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeSame);
            }
            return;
        }

        public set txTips(arg1: string)
        {
            this._txTips = arg1;
            (this._keyTxArr[2] as Object /* flash.text.TextField */).htmlText = "<font color=\'#00ff00\'>" + arg1 + "</font>";
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            this.setSize(300, 342);
            this.titleHeight = 28;
            this.title = Language.getString(54049);
            this._bg = ObjCreate.createBg(18, 39, 264, 293, this);
            ObjCreate.createBg(68, 40, 166, 25, this, ImagesConst.TileBg);
            ObjCreate.createBg(68, 176, 139, 24, this, ImagesConst.TileBg);
            ObjCreate.createLabel(Language.getString(70267), 99, 42, 100, 20, flash.text.TextFormatAlign.CENTER, this, false, GlobalStyle.color6Uint);
            ObjCreate.createLabel(Language.getString(70268), 99, 179, 100, 20, flash.text.TextFormatAlign.CENTER, this, false, GlobalStyle.color6Uint);
            ObjCreate.createBg(28, 79, 66, 66, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.move(31, 82);
            this._baseItem.setSize(60, 60);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            this._baseItem.isShowToolTip = false;
            addChild(this._baseItem);
            var loc5=[Language.getString(70269), Language.getString(70203), Language.getString(70270)];
            var loc6=0;
            while (loc6 < 5) 
            {
                loc1 = ResouceConst.getScaleBitmap(ImagesConst.SplitLine);
                if (loc6 == 0 || loc6 == 4) 
                {
                    loc1.x = 22;
                    loc1.width = 255;
                }
                else 
                {
                    loc1.x = 107;
                    loc1.width = 150;
                }
                loc1.y = 66 + loc6 * 27;
                addChild(loc1);
                if (loc6 > 1) 
                {
                    loc2 = ObjCreate.createTextField(loc5[loc6 - 2], 120, 70 + (loc6 - 2) * 27, 62, 20, this, new GTextFormat(FontUtil.songtiName, 12, 260112383), false, false);
                    loc4 = ObjCreate.createBitmap("", 225, 70 + (loc6 - 2) * 27, this);
                    this._bmArr.push(loc4);
                }
                if (loc6 > 0) 
                {
                    loc3 = ObjCreate.createTextField("", 185, 70 + (loc6 - 1) * 27, 42, 20, this);
                    loc3.autoSize = flash.text.TextFieldAutoSize.CENTER;
                    if (loc6 == 4) 
                    {
                        loc3.x = 18;
                        loc3.width = 256;
                    }
                    this._keyTxArr.push(loc3);
                }
                ++loc6;
            }
            this._tipTxtHight = ObjCreate.createTextField("", 26, 202, 245, 60, this);
            this._tipTxtHight.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._tipTxtHight.multiline = true;
            this._tipTxtHight.wordWrap = true;
            this._tipTxt = ObjCreate.createTextField("", 24, 202, 247, 20, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._delInput = ObjCreate.createGTextInput(84, 267, 135, 20, this);
            this._delInput.maxChars = 6;
            this._delInput.restrict = "A-z";
            this._okBtn = ObjCreate.createGButton(Language.getString(54055), 66, 298, 70, 27, this);
            this._okBtn.name = "ok";
            this._cancelBtn = ObjCreate.createGButton(Language.getString(54052), 164, 298, 70, 27, this);
            this._cancelBtn.name = "cancel";
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        public MountExtendAlertWindow.get deputyInfo(): ItemData
        {
            return this._deputyInfo;
        }

        public set deputyInfo(arg1: ItemData)
        {
            this._deputyInfo = arg1;
            if (arg1) 
            {
                if (this._deputyInfo.color > this._mainInfo.color) 
                {
                    (this._keyTxArr[3] as Object /* flash.text.TextField */).htmlText = Language.getString(70221);
                    (this._bmArr[0] as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeDecline);
                    EffectManager.glowFilterReg(this._bmArr[0] as Object /* flash.display.Bitmap */, [FilterConst.fightAvatarFilter]);
                }
                else 
                {
                    (this._keyTxArr[3] as Object /* flash.text.TextField */).htmlText = Language.getString(70220);
                    if (this._mainInfo.color >= this._deputyInfo.color) 
                    {
                        (this._bmArr[0] as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeSame);
                    }
                    else 
                    {
                        (this._bmArr[0] as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeRaise);
                    }
                }
                if (this._deputyInfo.color >= EColor._EColorPurple) 
                {
                    this._tip = Language.getStringByParam(70218, ItemsUtil.getItemName(arg1));
                }
                else 
                {
                    this._tip = Language.getStringByParam(70219, ItemsUtil.getItemName(arg1));
                }
                this._tipTxtHight.htmlText = this._tip;
                this._tipTxt.htmlText = this._tip;
                (this._keyTxArr[0] as Object /* flash.text.TextField */).htmlText = MountUtil.getColorAndRealColorName(this._mainInfo.color);
            }
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc2=null;
            var loc1=arg1.target as GButton;
            if (this._deputyInfo) 
            {
                if (loc1.name != "ok") 
                {
                    this.hide();
                }
                else 
                {
                    if (this._mode == MountExtendAlertWindow.ValidateMode) 
                    {
                        loc2 = this._delInput.text.toLocaleLowerCase();
                        if (StringHelper.getCharLength(StringHelper.trim(loc2)) == 0) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(54054));
                            return;
                        }
                        if (loc2 != "delete") 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(54054));
                            return;
                        }
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MountGoExtend, {"main": _mainInfo, "deputy": _deputyInfo, "growthSelect": _growthSelect}));
                    this.hide();
                }
            }
            return;
        }

        public set mode(arg1: int)
        {
            this._mode = arg1;
            if (arg1 != MountExtendAlertWindow.NormalMode) 
            {
                this.setSize(300, 342);
                this._bg.height = 293;
                this._okBtn.y = 298;
                this._cancelBtn.y = 298;
                this._delInput.visible = true;
                this._tipTxtHight.visible = true;
                this._tipTxt.visible = false;
            }
            else 
            {
                this.setSize(300, 280);
                this._bg.height = 228;
                this._okBtn.y = 233;
                this._cancelBtn.y = 233;
                this._delInput.visible = false;
                this._tipTxtHight.visible = false;
                this._tipTxt.visible = true;
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this._delInput.text = "";
            EffectManager.glowFilterUnReg(this._bmArr[0] as Object /* flash.display.Bitmap */);
            return;
        }

        public MountExtendAlertWindow.get mainInfo(): ItemData
        {
            return this._mainInfo;
        }

        /* internal */ /* var */_mode: int;

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_delInput: GTextInput;

        /* internal */ /* var */_tipTxtHight: Object /* flash.text.TextField */;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_delTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_mainInfo: ItemData;

        /* internal */ /* var */_deputyInfo: ItemData;

        /* internal */ /* var */_growthSelect: int;

        /* internal */ /* var */_tip: string="";

        /* internal */ /* var */_huanLv: int;

        /* internal */ /* var */_txTips: string;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_keyTxArr: Array<any>;

        public static /* var */ValidateMode: int=1;

        /* internal */ static /* var */_instance: MountExtendAlertWindow;

        public static /* var */NormalMode: int=0;

        /* internal */ /* var */_bmArr: Array<any>;
    }
